<template>
  <view>
    <text>{{ `请输入指定结果的次数(当前设置为${text}):` }}</text>
    )
    <uni-easyinput v-model="value" class="uni-mt-5" placeholder="请输入内容" trim="all" @input="input"></uni-easyinput>
    <button @click="check">确定</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      value: 0,
      text: 0
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    input() {

    },
    init() {
      uni.request({
        url: 'https://ex.tuzigo.com/getCode',
        success: (res) => {
          let resData = res.data.data;
          if (resData.length) {
            this.text = resData[0].code
          }
        }
      });
    },
    check() {
      uni.request({
        url: 'https://ex.tuzigo.com/setCode',
        method: 'post',
        data: {
          code: this.value
        },
        success: (res) => {
          uni.showToast({
            title: '设置成功',
            duration: 2000
          });
          this.init()
        }
      });
    }
  }
}
</script>

<style>
</style>
